Mega Code Archive
Aggregate Functions
1) A common mistake with DISTINCT is to code the DISTINCT statement before the COUNT statement
2) A summary query that uses the COUNT, AVG, and SUM functions
3) A summary query that uses the MIN and MAX functions
4) A summary query that works on non-numeric columns
5) Adds the WHERE statement to calculate the average
6) Aggregate function in sub query
7) Aggregate function, order by desc, group by
8) Aggregate functions are applied to a group of data values from a column
9) AVG calculates the average for selected records of numeric data in a column or the average for DISTINCT (unique) value
10) CAST(AVG(dec1) AS dec(5,2))
11) Count function with column alias
12) COUNT returns the total count of records in a column or the count for DISTINCT (unique) values selected by the query.t
13) Count table row in dynamic sql
14) COUNT() returns the total count of all records (rows) in the column, including NULL values of selected records by the
15) Counting unique values
16) Counting values including NULL values
17) Finding the Earliest Date Using MIN()
18) Finding the First Order for Each Customer Using MIN()
19) Finding the Last Row in Employee Using MAX()
20) Finding the smallest and largest selling prices
21) HAVING SUM(Salary) 1000
22) Id = (SELECT MIN(id) FROM employee)
23) MAX returns the largest value in a column of all selected records by the query of any char, number, or datetime dataty
24) MIN returns the smallest value in a column of all selected records by the query of any char, number, or datetime datat
25) Query Using MIN() and MAX() on Same Column
26) Query with aggregate function as a column
27) RANK() OVER
28) Returning Rows by Rank Without Gaps
29) Selecting titles that sell more than the average
30) Sum function with column alias
31) SUM returns the total value in a column of all selected records or all the DISTINCT (unique) values selected by the qu
32) Sum with CUBE
33) SUM with group by
34) SUM with WITH ROLLUP
35) The RANK() function preserves the ordinal position of the row in the list
36) The use of the aggregate function MAX in subquery
37) Using Aliase with aggregate function
38) Using calculations within aggregate functions
39) Using DISTINCT in Aggregate Functions
40) Using ISNULL to count all values including NULLs